package src.zhuzi.spring.aop;

public class CalFaberRicciImpl implements ICalFaberRicci{

	@Override
	public long calFaberRicciByLoop(long n) {
		long n3 = 1;
		if(n == 2) n3 = 2;
		if(n > 2) {
			long n1 = 1;
			long n2 = 2;
			for(long i=2;i<n;i++) {
				n3 = n1 + n2;
				n1 = n2;
				n2 = n3;
			}
		}
		return n3;
	}

	@Override
	public long calFaberRicciByRecursion(long n) {
		if(n == 1) return 1;
		if(n == 2) return 2;
		return calFaberRicciByRecursion(n-1)+calFaberRicciByRecursion(n-2);
	}

	/*@Override
	public long statPerform(String method, long n) {
		long start = System.currentTimeMillis();
		if(method.equals("calFaberRicciByLoop")) {
			calFaberRicciByLoop(n);
		}else {
			calFaberRicciByRecursion(n);
		}
		long end = System.currentTimeMillis();
		return end - start;
	}*/
}